package com.xdclass.mysql.controller;

import com.google.common.collect.Lists;
import com.xdclass.mysql.constant.RestItemResult;
import com.xdclass.mysql.dao.UserDao;
import com.xdclass.mysql.mapper.custom.CustomUserMapper;
import com.xdclass.mysql.mapper.generator.ProductMapper;
import com.xdclass.mysql.mapper.generator.UserMapper;
import com.xdclass.mysql.model.domain.ProductModel;
import com.xdclass.mysql.model.domain.User;
import com.xdclass.mysql.model.domain.UserModel;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @author daniel
 */
@RestController
@RequestMapping("/product")
public class ProductController {

    @Resource
    private ProductMapper productMapper;

    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public RestItemResult add() {
        RestItemResult result = new RestItemResult<>();
        for (int i = 10000; i < 11000; i++) {
            ProductModel model = new ProductModel();
            model.setCreateTime(LocalDateTime.now());
            model.setProductSeq("productSeq" + i);
            model.setSaleId("saleId" + i);
            model.setSkuId("skuId" + i);
            model.setSpuId("spuId" + i);
            model.setStoreId((long)i);
            model.setValid(true);
            productMapper.insertSelective(model);
        }
        result.setResult("success");
        return result;
    }

    @RequestMapping(value = "/locate/{id}", method = RequestMethod.GET)
    public RestItemResult<ProductModel> locate(@PathVariable Long id) {
        RestItemResult<ProductModel> result = new RestItemResult<>();

        return result;
    }

    
}
